<?php
/**
 * 基础验证
 * Date: 2021/10/13
 */

namespace app\common\validate;
use think\Validate;
class UserInfo extends Validate{
    // 需要验证的字段
    protected $rule = [
        'id'=>'require|length:5,30|alphaDash',
        'name'=>'require|length:5,30|alphaDash',
        'page'=>'require|number',
        'limit'=>'require|number',
    ];
    // 对应的提示
    protected $message =[
        'user_number.require'  => '账号必须',
        'user_number.length'  =>  '账号长度范围5-30个字符',
        'user_number.alphaDash'  => '账号规则,字母和数字，下划线_及破折号-',
        'user_pass.require'  => '密码必须',
        'user_pass.length'  =>  '密码长度范围5-30个字符',
        'user_pass.alphaDash'  => '密码规则,字母和数字',
        'user_id.require'=> '非法ID',
        'user_id.number'=> '非法ID',
    ];
    // 自定义方法

    // 验证场景
    protected $scene = [
        'login' => ['user_number','user_pass'] ,
        'userInfo' => ['user_id'] ,
    ];
}
